package com.company.vmvp.ui.personal.presenter;


import com.company.vmvp.api.HttpManager;
import com.company.vmvp.api.ResultEntity;
import com.company.vmvp.api.RxSubscriber;
import com.company.vmvp.ui.main.entity.UserBean;
import com.company.vmvp.ui.personal.contract.PersonalContract;
import com.dee.components.baserx.RxSchedulers;

import java.util.HashMap;


/**
 * 作者：Administrator on 2017/12/04 10:36
 * 当前类注释:
 * Presenter
 */
public class PersonalPresenter extends PersonalContract.Presenter {
    @Override
    public void getData(String type) {
        //请求参数
        HashMap<String, String> param = new HashMap<>();
        param.put("type", type);
        HttpManager.getInstance().getOkHttpUrlService().getUserData(param)
                .compose(RxSchedulers.<ResultEntity<UserBean>>io_main())
                .subscribe(new RxSubscriber<ResultEntity<UserBean>>(this) {
                    @Override
                    public void _onNext(ResultEntity<UserBean> data) {
                        mView.return_Data(data.getData());
                    }

                    @Override
                    public void onErrorSuccess(int code, String message, boolean issuccess) {
                        mView.onErrorSuccess(code, message, issuccess, false);
                    }
                });
    }
}
